home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Disc to the Future 2
/
Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin
/
MAC
/
'92_HACK
/
CHANGE_T
/
GENERIC_.C
next >
Wrap
Text File
|
1991-06-05
|
3KB
|
115 lines
#define OKButton 1
/************************************************************************
*
* Function: OutlineOK
*
* Purpose: outline the OK button in a dialog
*
* Returns: nothing
*
* Side Effects: standard box is drawn around OK button
*
* Description: draws the heavy rounded box around the OK button,
* so that the user knows that hitting enter or return
* is the same as pressing the OK button. OK is assumed
* to be the first item in the dialog.
*
************************************************************************/
void
OutlineOK(dPtr)
DialogPtr dPtr;
{
int unusedItemType;
Handle unusedItemHandle;
Rect box;
PenState p;
GrafPtr savedPort;
/* This next little piece of code puts the default heavy rounded
box around the "OK" button, so the user knows that pressing
return is the same as hitting "OK"
*/
GetPort(&savedPort);
SetPort(dPtr); /* without this, can't highlite OK */
GetDItem(dPtr, OKButton, &unusedItemType, &unusedItemHandle, &box);
GetPenState(&p);
PenSize(3,3);
InsetRect(&box, -4, -4);
FrameRoundRect(&box, 16, 16);
PenSize(p.pnSize.h, p.pnSize.v);
SetPort(savedPort);
}
/************************************************************************
*
* Function: GenericFilter
*
* Purpose: generic dialog filter
*
* Returns: true if nothing has happened, false if a choice has
* been made. itemHit is modified to return the value
* of the item selected.
*
* Side Effects: Handles cut, copy, paste, cancel for system 6.
*
* Description: You'll get either an updateEvt, a keyDown, or an
* autoKey. On updateEvt, handle window updates and
* if necessary, draw the OK outline. If a keydown (or
* autokey) handle the key as apporpriate.
*
************************************************************************/
pascal Boolean GenericFilter(DialogPtr theDialog,EventRecord *theEvent,short *itemHit)
{
WindowPtr updateWindow;
char theChar;
switch (theEvent->what) {
case updateEvt:
updateWindow = (WindowPtr) theEvent->message;
if (updateWindow!=theDialog)
HandleUpdates(updateWindow); /* <<<----- call window updates here */
else
OutlineOK(theDialog); /* <<<--- I draw ok outline here */
break;
case keyDown:
case autoKey:
theChar = theEvent->message & charCodeMask;
if ((theEvent->modifiers & cmdKey) != 0) {
switch (theChar) {
case 'x':
DlgCut(theDialog);
*itemHit = 0;
return true;
case 'c':
DlgCopy(theDialog);
*itemHit = 0;
return true;
case 'v':
DlgPaste(theDialog);
*itemHit = 0;
return true;
case '.':
*itemHit = Cancel;
return true;
default:
return false;
break;
}
}
else switch (theChar) {
case 0x0d: /* CR */
case 0x03: /* enter */
*itemHit = OK;
return true;
case 0x1b: /* ESC */
*itemHit = Cancel;
return true;
}
break;
}
return false;
}